/***
 * @title: sys_log ServiceImpl file
 * @author: seasonszx dev
 * @datetime: 2018-01-24 14:08:07
 * @version: 1.0.0
 */
package com.zx.platform.zanadu.manager.rpc.apiimpl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zx.platform.zanadu.manager.mapper.SysLogMapper;
import com.zx.platform.zanadu.manager.mongo.bean.SysLogRepository;
import com.zx.platform.zanadu.manager.pojo.SysLog;
import com.zx.platform.zanadu.manager.rpc.api.RpcSysLogService;
import com.zx.platform.zanadu.manager.util.MongoDAO;


@Service
@Transactional
public class RpcSysLogServiceImpl implements RpcSysLogService {

	@Autowired
    private SysLogMapper sysLogMapper;
	
	@Autowired
	MongoOperations mongoOperations;
	
	@Autowired
	SysLogRepository sysLogRepository;
	
	@Autowired
	MongoTemplate mongoTemplate;
	
	@Override
	public int dubboMongodbCommonJsonStrInsert(String collName ,String jsonStr) {
		//原生态的mongoDB插入json，原理是：json转Document
		MongoDAO.insertJson("zanadu", collName, jsonStr);
		return 1;
	}

	@Override
	public int dubboMongodbObjectInsert(SysLog info) {
//		mongoOperations.insert(info);	//作用等同于mongoTemplate
//		mongoOperations.save(info);		//作用等同于insert()
//		sysLogRepository.save(info); 	//该对象必须包含id属性，否则插入失败
		mongoTemplate.insert(info);
		return 1;
	}

	@Override
	public int dubboMysqlObjectInsert(SysLog info) {
		return sysLogMapper.insert(info);
	}


}
